package cn.wolfcode.mq;

import cn.wolfcode.web.controller.OrderInfoController;
import cn.wolfcode.web.controller.SeckillProductController;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 修改本地标识为false, 即改变为还有库存的状态
 */
@Slf4j
@Component
@RocketMQMessageListener(
        consumerGroup = "MQCanalSignListener123",
        topic = MQConstant.CANCEL_SECKILL_OVER_SIGE_TOPIC,
        messageModel = MessageModel.BROADCASTING    // 设置消费者的消息消费模式为广播模式
)
public class MQCanalSignListener implements RocketMQListener<Long> {

    @Override
    public void onMessage(Long seckillId) {
        // 修改本地标识 为false 即还有库存的状态
        OrderInfoController.IS_USE_OUT.put(seckillId,false);
    }
}
